<?php 
	$cateModel = new \Common\Model\Cate;  
	// ==>顶级分类
	$topCate = $cateModel->where("pid=0")->orderBy('sort','ASC')->get();
	//重组数组，便于前台数组遍历
	foreach($topCate as $k=>$v){
		//新增字段 son 	==> 一级分类
		$topCate[$k]['son'] = $cateModel->where('pid',$v['cid'])->orderBy('sort','ASC')->get();
		foreach($topCate[$k]['son'] as $kk=>$vv){
			//新增字段 grandson 	==> 二级分类
			$topCate[$k]['son'][$kk]['grandson']=$cateModel->where('pid',$vv['cid'])->orderBy('sort','ASC')->get();
		}
	}	
	
	//判断用是否登录
	if(isset($_SESSION['user'])){
		$user = $_SESSION['user'];
	}	
	
	/*购物车*/
	//先开启$_SESSION['cart']
	Cart::getGoods(); 
	//购物车商品总数
	$goodsNum = Cart::getTotalNums();		

?>


<!--header-->
<header>
	<!--顶层-->
	<div class="header_top">
		<div class="header_c">
			<ul class="h_menu">
				<li class="li_left">
					<?php if(!isset($_SESSION['user'])) :?>
					<a href="<?php echo U('Member/index')?>">欢迎登录名鞋库</a>&nbsp;
					<a href="<?php echo U('Member/register')?>">免费注册</a>	
					<?php else :?>
						欢迎您，<a href="<?php echo U('Individual/index',['cid'=>$_GET['cid']])?>"><span class="account"><?php echo $user['account']?></span></a> ！
						<a href="<?php echo U('Member/out')?>"><span class="out">[退出]</span></a>
					<?php endif ?>	
				</li>
				<li class="li_left_w">
					<?php if(isset($_SESSION['user'])) :?>
					<p><a href="<?php echo U('Individual/index',['cid'=>$_GET['cid']])?>">我的名鞋库</a></p>
					<?php else :?>
					<p><a href="<?php echo U('Member/index')?>">我的名鞋库</a></p>	
					<?php endif ?>											
					<!--<div class="show_hide">
						<a href="">我的订单</a>
						<a href="">密码管理</a>
					</div>-->
				</li>
				<!--<li>
					<p><a href="">手机名鞋库</a></p>
				</li>-->
				<!--<li>
					<span><a href="">收藏名鞋库</a></span>
				</li>-->
				<!--<li>
					<p><a href="">名鞋店客服</a></p>
				</li>-->
				<li>
					<p><a href="" style="color: #A21F25;font-size: 16px;font-weight: 700;">18303099587</a></p>
				</li>
			</ul>
		</div>
	</div>
	<!--搜索区-->
	<div class="header_center">
		<div class="logo"></div>
		<div class="sub_help">
			<div class="shop">
				<a href="<?php echo U('ShopCar/index',['cid'=>$_GET['cid']])?>">
					<div class="shop_picture">
						购物车 
						<span id="a"><?php echo $goodsNum?></span>
						件
					</div>
				</a>
			</div>
			<div class="search">
				<form class="search_top" action="" method="post">
					<!--********************************************************-->
					<input class="search_content" type="text" value="记得要填！！" />
					<input class="searchbtn" type="button" value="搜索" />
					
				</form>
				<!--<span>热搜：</span>
				<ul class="keyword">
					<li><a href="">后台数据遍历</a></li>
					<li><a href="">后台数据遍历</a></li>
					<li><a href="">后台数据遍历</a></li>
					
				</ul>-->
			</div>
		</div>
		
	</div>
</header>
<!--endheader-->

<!--banner-->
<nav id="nav_head">
	<div class="nav_body">						
		<div class="nav_left">
			所有商品分类
			<ul class="nav_menu">
				<?php foreach ($topCate as $k=>$v){?>
				<li> 	
					<!--顶级分类	背景logo-->		
					<div class="menu_name name_logo_<?php echo $k?>">
						<a href="<?php echo U('List/index',array('cid'=>$v['cid']))?>"><?php echo $v['cname']?></a>				
					</div>		
					<div class="menu_hide">
						<?php foreach ($v['son'] as $kk=>$vv){?>
						<div class="menu_hide_logo">
							<!--一级分类	背景logo-->
							<div class="menu_hide_go">
								<h4><?php echo $vv['cname']?></h4>
							</div>					
						</div>
						<!--二级分类-->
						<ul class="menu_hide_content">
							<?php foreach ($vv['grandson'] as $vvv){?>
							<li><a href="<?php echo U('List/index',['cid'=>$k])?>"><?php echo $vvv['cname']?></a></li>
							<?php }?>			
						</ul>
						<?php }?>			
					</div>
				</li>
				<?php }?>
				<li>
					<div class="menu_name name_logo_7">
						<a href="<?php echo U('List/index',array('cid'=>$v['cid']))?>">男鞋</a>				
					</div>
				</li>
				<li>
					<div class="menu_name name_logo_8">
						<a href="<?php echo U('List/index',array('cid'=>$v['cid']))?>">童鞋</a>				
					</div>
				</li>
			</ul>				
		</div>
		
		<ul class="nav_center">
			<a href="index.php"><div class="home">首页</div></a>
			<?php foreach ($topCate as $v){?>
			<li>
				<a href="<?php echo U('List/index',['cid'=>$v['cid']])?>" <?php if(isset($v['cid']) && $v['cid'] == $_GET['cid']){?>
                class="hover"
               <?php }?>><?php echo $v['cname']?></a>
				</li>		
			<?php }?>					
		</ul>
	</div>
</nav>
<!--endbanner-->